import React, { Component } from 'react'
import { Provider } from 'react-redux'
import { Router, browserHistory } from 'react-router'

import App from './App'
import Index from '../routes/index/containers/Index'

const rootRoute = {
  component: 'div',
  childRoutes: [{
    path: '/',
    component: App,
    childRoutes: [
      ...require('../routes/index'),
      ...require('../routes/article')
    ],
    onEnter: function(nextState, replaceState){
       if(nextState.location.pathname=="/"){
         replaceState(null, '/articles/1')
       }
     }
  }]
}

export default class Root extends Component {
  render() {
    const { store } = this.props;
    return (
      <Provider store={store}>
        <div>
          <Router history={browserHistory} routes={rootRoute} />
        </div>
      </Provider>
    );
  }
}
